/*
 * File:   calculator.h
 * Author: ScaV
 *
 * Created on November 26, 2011, 3:33 PM
 */

#ifndef CALCULATOR_H
#define	CALCULATOR_H

#include "infint.h"
#include <stack>
#include <queue>

enum PRIOR {
	PRIOR_UNKNOWN = 0,
	PRIOR_PLUS = 1, PRIOR_MINUS = 1,
	PRIOR_PRODUCT = 2, PRIOR_DIVIDE = 2,
	PRIOR_POWER = 3,
	PRIOR_UNAR_MINUS = 4,
	PRIOR_FACTORIAL = 5
};

class calculator {
public:
	calculator();
	calculator(const calculator& orig);
	virtual ~calculator();
	int setExp(const char *str);
	infint operator ()(const char *str) { return calc(str); };
private:
	PRIOR getPriority(char ch);
	infint calc(const char *str);
	void reset();

	std::queue<char*> out;
	std::stack<char*> stc;
	std::stack<infint*> cstc;
};

#endif	/* CALCULATOR_H */

